package com.example.myapp.Fragment;


import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.example.myapp.ADO.RecordAdopter;
import com.example.myapp.ADO.TabAdaper;
import com.example.myapp.Loading.ShapeLoadingDialog;
import com.example.myapp.Model.Record;
import com.example.myapp.Model.User;
import com.example.myapp.R;
import com.example.myapp.RecordFragemt.Fragment1;
import com.example.myapp.RecordFragemt.Fragment2;
import com.google.android.material.tabs.TabLayout;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.BmobUser;
import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.FindListener;

//import android.support.v4.app.Fragment;


/**
 * A simple {@link Fragment} subclass.
 * Use the {@link RecordFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class RecordFragment extends Fragment {
    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
    private static final String ARG_SHOW_TEXT = "text";

    private String mContentText;
    private ShapeLoadingDialog shapeLoadingDialog;
    private ListView lsitnew;
    private Date createdAtDate;
    private   List<Record>  recordList=new ArrayList<>();
    public RecordFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param param1 Parameter 1.
     * @return A new instance of fragment HomeFragment.
     */
    public static RecordFragment newInstance(String param1) {
        RecordFragment fragment = new RecordFragment();
        Bundle args = new Bundle();
        args.putString(ARG_SHOW_TEXT, param1);
        fragment.setArguments(args);
        return fragment;
    }



    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mContentText = getArguments().getString(ARG_SHOW_TEXT);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_record, container, false);
        TabLayout tabLayout=rootView.findViewById(R.id.tab);
        ViewPager viewPager=rootView.findViewById(R.id.viewpager);
        List<Fragment> fragments = new ArrayList<>();
        String[] titles = new String[]{"丢失","捡到"};
        fragments.add(Fragment1.newInstance("传递参数1"));
        fragments.add(Fragment2.newInstance("传递参数2"));
        TabAdaper adapter = new TabAdaper(getChildFragmentManager(), fragments, titles);//getChildFragmentManager 的意思是 创建子容器
        viewPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewPager);

        return rootView;
    }







}
